<?php

/**
 * Site form.
 *
 * @package    Web20
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class SiteForm extends BaseSiteForm
{
  public function configure()
  {
	unset($this["created_at"], $this["updated_at"]);

	$this->setWidgets(array(
       	'id'	  	 	=> new sfWidgetFormInputHidden(),
      	'user_id'		=> new sfWidgetFormInputHidden(),
      	'name'			=> new sfWidgetFormInput(array('label' => "Nombre"), array('size' => 20)),
      	'description'	=> new sfWidgetFormTextareaTinyMCE(array(
							'label' => "Descripción",
							'width' => 350,
							'height' => 250,
							'theme' => "simple",
							'config' => 'theme_advanced_disable: "anchor,image,cleanup,help"',
							)),
      	'logo'			=> new sfWidgetFormInputFileEditable(
			array(
				'label'	   => "Logo",
				'file_src' => $this->getObject()->getLogoFileName(),
				'is_image' => true,
				'delete_label' => "Eliminar",
				'template'  => '<div style:"float:left;">%file%</div>
						<div>%input%
						%delete% %delete_label%</div>
						',
			)),
		'payment_enabled' => new sfWidgetFormInputCheckbox(array('label' => "Plataforma de pagos")),
		'dineromail_store_id' => new sfWidgetFormInput(array('label' => "Cuenta de Dineromail")),
		'background_image'	=> new sfWidgetFormInputFileEditable(
			array(
				'label'	   => "Imagen de Fondo",
				'file_src' => $this->getObject()->getBackgroundImageFileName(),
				'is_image' => true,
				'delete_label' => "Eliminar",
				'template'  => '<div style:"float:left;">%file%</div>
						<div>%input%
						%delete% %delete_label%</div>
						',
			)),
		'color_1' => new sfWidgetFormInput(array('label' => "Color 1", 'default' => "#000000"), array('size' => 6)),
		'color_2' => new sfWidgetFormInput(array('label' => "Color 2", 'default' => "#000000"), array('size' => 6)),
		'color_3' => new sfWidgetFormInput(array('label' => "Color 3", 'default' => "#000000"), array('size' => 6)),
		'location' => new sfWidgetFormInput(array('label' => "Ubicación"), array('size' => 20)),
		'font' => new sfWidgetFormChoice(array(
			'label' => "Tipo de letra",
			'choices' => array(
				"Arial, Helvetica, sans-serif" => "Arial, Helvetica, sans-serif",
				"'Arial Black', Gadget, sans-serif" => "Arial Black, Gadget, sans-serif",
				"'Bookman Old Style', serif" => "Bookman Old Style, serif",
				"'Comic Sans MS', cursive" => "Comic Sans MS, cursive",
				"Courier, monospace" => "Courier, monospace",
				"'Courier New', Courier, monospace" => "Courier New, Courier, monospace",
				"Garamond, serif" => "Garamond, serif",
				"Georgia, serif" => "Georgia, serif",
				"Impact, Charcoal, sans-serif" => "Impact, Charcoal, sans-serif",
				"'Lucida Console', Monaco, monospace" => "Lucida Console, Monaco, monospace",
				"'Lucida Sans Unicode', 'Lucida Grande', sans-serif" => "Lucida Sans Unicode, Lucida Grande, sans-serif",
				"'MS Sans Serif', Geneva, sans-serif" => "MS Sans Serif, Geneva, sans-serif",
				"'MS Serif', 'New York', sans-serif" => "MS Serif, New York, sans-serif",
				"'Palatino Linotype', 'Book Antiqua', Palatino, serif" => "Palatino Linotype, Book Antiqua, Palatino, serif",
				"Symbol, sans-serif" => "Symbol, sans-serif",
				"Tahoma, Geneva, sans-serif" => "Tahoma, Geneva, sans-serif",
				"'Times New Roman', Times, serif" => "Times New Roman, Times, serif",
				"'Trebuchet MS', Helvetica, sans-serif" => "Trebuchet MS, Helvetica, sans-serif",
				"Verdana, Geneva, sans-serif" => "Verdana, Geneva, sans-serif",
				"Webdings, sans-serif" => "Webdings, sans-serif",
				"Wingdings, 'Zapf Dingbats', sans-serif" => "Wingdings, Zapf Dingbats, sans-serif"),
			)),
		'category_id' => new sfWidgetFormDoctrineChoice(array(
			  'label'	  => "Categoría",
			  'model'     => 'Category',
			  'add_empty' => true,
			)),
	));

    $this->validatorSchema['logo'] = new sfValidatorFile(array(
		    'required' => false,
			'max_size' => '5242880',
			'path' => sfConfig::get('sf_upload_dir'),
			'mime_types' => 'web_images'),
			array('max_size' => 'El tamaño máximo es de 5MB',
				'mime_types' => 'Sólo se permiten imágenes jpg, png o gif'));

    $this->validatorSchema['background_image'] = new sfValidatorFile(array(
		    'required' => false,
			'max_size' => '5242880',
			'path' => sfConfig::get('sf_upload_dir'),
			'mime_types' => 'web_images'),
			array('max_size' => 'El tamaño máximo es de 5MB',
				'mime_types' => 'Sólo se permiten imágenes jpg, png o gif'));

	$this->setValidator('description', new sfValidatorString(array('required' => false)));
	$this->setValidator('color_1', new sfValidatorString(array('required' => true)));
	$this->setValidator('color_2', new sfValidatorString(array('required' => true)));
	$this->setValidator('color_3', new sfValidatorString(array('required' => true)));

	$this->widgetSchema->setNameFormat('site[%s]');
	$this->validatorSchema->setOption('allow_extra_fields', true);
  }
}
